<?php
namespace app\wxapp\controller;

use app\model\Record; 
use app\model\Fee; 
use app\model\Comm; 
use app\model\Theme; 
use app\model\Poster; 
use app\model\Worker; 
use app\model\Fans; 
use app\model\Order; 
use app\model\Share; 
use app\model\Relation; 
use app\model\Scan; 

class Index extends Base
{
    public function Index()
    {
global $_P, $_G;
$fans = $this->checkuser();
$system=$_G['system'];
// var_dump($system);
$themeid = intval($_P['themeid']);
$theme = Theme::getThemeByIdxcx($themeid);
if(empty($theme['id'])){
    $this->result(1, '活动入口不正确');
    exit;
}
// yxlog("小程序" . $_G['member']['uid'] .'___'. $_G['member']['unionid']);
if (intval($fans['status'])<1 && !empty($fans)){
    $result =  array();
    $result['fansstatus'] = $fans['status'];
    $this->result(0, '成功', $result);
    exit;
}




$config =   Theme::getConfig($themeid);
if (empty($config['bannerimgs']) && !empty($config['headlogo'])) {
    $config['bannerimgs'][0] =$config['headlogo'];
}

if (TIMESTAMP > $theme['endtime']) {
    if(DOMAIN0 == "30.yixuan.net" ){
        $theme['endtime']= TIMESTAMP+86400;;
        $theme['status']=1;
        db_update(t_theme, array("status"=>1,"endtime"=>$theme['endtime']), array('id' => $themeid));
    }else{
        db_update(t_theme, array("status"=>2), array('id' => $themeid));
        $theme['status'] = 2;
    }
}

if (empty($system['endday'])) {
    $endday = 5;
}else{
    $endday = $system['endday'];
}
$endday = $endday*24*3600;

if ($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) {
    $recordid = 0;
    $config['musicsrc']="http://img2019.yixuansoft.cn/audios/2/2020/02/P30ZcCUDrmsCll9La3MNnAd36MRXS3.mp3";
    if ($system['s']['ishongbao']==1) {
        $system['fenxiao'] = 0;
        $config['iscomm'] = 0;
    }
    if ($system['s']['isfenxiao']==1) {
        $system['fenxiao01'] = 0;
        $config['danmu02'] = 1;
        $config['danmu03'] = 1;
    }
    if ($system['s']['iszhuanfa']==1) {
        $system['fenxiao04'] = 0;
        $config['danmu03'] = 1;
        $config['danmu04'] = 1;
    }
    if ($system['s']['isyaoyiyao']==1) {
        $system['fenxiao07'] = 0;
        $config['danmu03'] = 1;
        $config['danmu04'] = 1;
    }
    if ($system['s']['isticheng']==1) {
        $system['fenxiao06'] = 0;
    }
    if ($system['s']['isyuedu']==1) {
        $system['fenxiao05'] = 0;
    }
    if ($system['s']['isicon']==1) {
        $config['isicon'] = 0;
        $config['danmu01'] = 1;
    }
    if ($system['s']['isfanpai']==1) {
        $system['fanpai'] = 0;
    }
    if ($system['s']['isfujintuan']==1) {
        $config['isrecent'] = 0;
        $config['marketprice'] = '0.00';
    }
    if ($system['s']['isjpeg']==1) {
        $config['headlogo']=str_replace(".jpeg",".jpg",$config['headlogo']);
    }
    if ($system['s']['istime']==1) {
        $config['istime']=10;
    }
    if ($system['s']['isheadimg']==1) {
        $config['iswttouxiang']=10;
    }
    if ($system['s']['isdanmu']==1) {
        $config['isdanmu']=0;
    }
}
if ($fans['status']==2){
    if ($system['s']['isbanquan']==1) {
        $theme['yixuanbanquan'] = 1;
    }
}



if ($config['maxcount']>0) {
$recordid = intval($_P['recordid']);
}
$record = Record::getAttendGroupByIdTuan($recordid);
if (!empty($record)){
    $recordid=$record['pid'];
}
if ($recordid>0) {//如果打开的团长是员工,强制清空
    $record = Record::getAttendGroupById($recordid);
    $myworker = Worker::getThemeWorkerByOpenid($record['openid'],$themeid,1);
    if (!empty($myworker)) {
        $recordid=0;
    }
}

//未支付的进行较验是否已支付
Order::checkorder($themeid,$config,$system);

$workerid = intval($_P['workerid']);
$p = array(":themeid"=>$themeid);
$pm = array(":themeid"=>$themeid,":openid"=>$fans['openid']);


//如果已定单,客服为定单客服
$p3 = array(":uid"=>$_G['member']['uid'],":themeid"=>$themeid);
$recordinfo = db_find ( "SELECT * FROM " . tablename (t_record) . "
                                WHERE themeid =:themeid
                                        and uid = :uid and type<>8 order by id desc limit 1",$p3);
if ($config['joinfee']=='0.00' && $config['groupprice']=='0.00'){
    $recordid = 0;
    $themyrecord = $recordinfo;
    if ($config['touxiang']==2) {
        $config['touxiang']=1;
    }
}else{
    $themyrecord = Record::getLastGroupByUid($_G['member']['uid'],$themeid);
}

if(!empty($themyrecord)){
    if ($themyrecord['type']==1){
        $recordid = $themyrecord['pid'];
    }else{
        $recordid = $themyrecord['id'];
        $isleader = 1;
    }
    $themyrecordid = $recordid+10000;
}
if ($config['wuxian']==1) {
    $themyrecordid = "";
}

//员工信息
$isgetworker = false;
$myworker = Worker::getThemeWorkerByOpenid($_G['openid'],$themeid,1);
if(!empty($myworker) && $system['ruanjian']==3 && $config['showshop']!=$myworker['company'] && $config['showshop']>0){
    $isgetworker = true;
}
if (empty($myworker) || $isgetworker){
    if(!empty($themyrecord)){
        $workerid = $themyrecord['workerid'];
    }else{
        $workerid = intval($_P['workerid']);
    }
    if ($workerid==0){
        $relation = Relation::getByThemeId($themeid,$fans['openid']);
        $workerid = $relation['workerid'];
    }
    $totalTheme = Theme::getTotal("status <> '-1' ");
    if ($totalTheme>1) {
        if ($isgetworker){//如果是异业的复制员工信息
            if(!empty(Worker::getThemeWorkerByOpenidAlltheme($fans['openid'],1)) && empty($myworker)){
                Worker::CopyThemeWorkerByUid($fans['uid'],$themeid,1);//复制员工信息到新活动
                if ($workerid != $fans['uid']){
                    $theyworker = Worker::getThemeWorkerByUid($workerid,$themeid,1);
                }
            }
        }else{
            if(!empty(Worker::getThemeWorkerByOpenidAlltheme($fans['openid'],1))){
                $theyworker = Worker::CopyThemeWorkerByUid($fans['uid'],$themeid,1);//复制员工信息到新活动
                yxlog($theyworker);
                $workerid = $fans['uid'];
            }elseif (!empty($workerid)){

                $theyworker = Worker::getThemeWorkerByUid($workerid,$themeid,1);

                if (empty($theyworker)){
                    $theyworker = Worker::CopyThemeWorkerByUid($workerid,$themeid,1);//复制员工信息到新活动
                }
            }
        }
    }elseif (!empty($workerid)){
        $theyworker = Worker::getThemeWorkerByUid($workerid,$themeid,1);
    }
    if ($isgetworker == false){
        $myworker = Worker::getThemeWorkerByOpenid($fans['openid'],$themeid,1);
    }else{
        $myworker = '';
    }
    if ($system['ruanjian']==3 && $config['showshop']>0 && $config['showshop']!=$theyworker['company'] ){
        $workerid = 0;
    }else{
        $workername = $theyworker['username'];
        $workermobile = $theyworker['mobile'];
        $company = $theyworker['company'];
        $workerqr = $theyworker['qrcode'];
        $wechat = $theyworker['wechat'];
        $workerposter = $theyworker['poster'];
    }
}else{

    $workerid = $myworker['uid'];
    $workername = $myworker['username'];
    $company = $myworker['company'];
    $workermobile = $myworker['mobile'];
    $workerqr = $myworker['qrcode'];
    $workerposter = $myworker['poster'];
    $wechat = $myworker['wechat'];
}


//更新浏览量

$pw = array(":workerid"=>$workerid);
db_query("UPDATE ".tablename(t_theme)." SET scansum = scansum +1 WHERE id =:themeid",$p);

db_query("UPDATE ".tablename(t_report)." SET scansum = scansum +1 WHERE software = '".MODULE_NAME."' and themeid =:themeid and riqi ='" . date("Y-m-d") ."'",$p);
db_query("UPDATE ".tablename(t_fans)." SET scansum = scansum +1 WHERE themeid =:themeid and openid = :openid",$pm);
db_query("UPDATE ".tablename(t_worker)." SET scansum = scansum +1 WHERE themeid = " . $themeid . " and uid =:workerid",$pw);
Theme::workerreport($themeid,$workerid,array('scansum' =>1));

$theme['scansum'] = $theme['scansum']+1;
//cache_write($cachekey, $theme);

if ($theme['status']==2 || $theme['endtime'] < TIMESTAMP){
    $theme['endtime']=TIMESTAMP;
}



    //参加人数
    if ($system['ruanjian']==0 && $system['softstyle']==5) {
        $total1 = Record::getNumByThemeId($themeid,$config['touxiang'],$config['showalldata']);

        $tiaojian =" WHERE recordid=99999 ";
        $sql = "SELECT * FROM " . tablename ( t_shengshi ) . " 
                  {$tiaojian} ORDER BY displayorder desc, areaId asc ";
        $list = db_select ( $sql );
        $total = db_fetchcolumn('SELECT COUNT(*) FROM ' .tablename(t_shengshi)."  {$tiaojian}");

        $totalsum = $total1 + $config['fakejoin'] + $total;
        $scannum = Record::getscannumByThemeId($themeid,$config['showalldata'])+intval($config['fakescan']);

    }elseif ($system['ruanjian']==3 && $system['softstyle']==2) {
        //参加人数
        $fanslist = Record::getFanslistByThemeIdall($themeid,$config['touxiang'],2000,$config['showalldata']);
        //隐藏客户真实姓名
        foreach ($fanslist as $index => $row){
            $usernamelen=mb_strlen($row['username'],'utf-8');
            if ($usernamelen > 2){
                $fanslist[$index]['username']=mb_substr($row['username'],0,1,'utf-8').'*'.mb_substr($row['username'],$usernamelen-1,1,'utf-8');
            }elseif (!empty($row['username'])){
                $fanslist[$index]['username']='*'.mb_substr($row['username'],-1,1,'utf-8');
            }

            $usernamelen=mb_strlen($row['mobile'],'utf-8');
            $fanslist[$index]['mobile']=mb_substr($row['mobile'],0,3,'utf-8').'****'.mb_substr($row['mobile'],$usernamelen-4,4,'utf-8');

        }
        $fanslisttop = Record::getFanslistByThemeIdall($themeid,$config['touxiang'],20,$config['showalldata']);

            foreach ($fanslisttop as $index => $row){

                $usernamelen=mb_strlen($row['mobile'],'utf-8');
                $fanslisttop[$index]['mobile']=mb_substr($row['mobile'],0,3,'utf-8').'****'.mb_substr($row['mobile'],$usernamelen-4,4,'utf-8');

            }
        $total1 = Record::getNumByThemeId($themeid,$config['touxiang'],$config['showalldata']);
        $totalsum = $total1 + $config['fakejoin'];
    }else{

        $scannum = Record::getscannumByThemeId($themeid,$config['showalldata'])+intval($config['fakescan']);
            $total1 = Record::getNumByThemeId($themeid,$config['touxiang'],$config['showalldata']);
            $totalsum = $total1 + $config['fakejoin'];
            if ($system['softstyle']==6){
                $txnum = 40;
            }else{
                $txnum = 60;
            }
            //参加人数
            if (!(($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['istouxiang']==1)) {
                if ($system['softstyle']==6){
                    $fanslist = Record::getFanslistByThemeIdjm($themeid,$config['touxiang'],$txnum);
                }else{
                    $fanslist = Record::getFanslistByThemeId($themeid,$config['touxiang'],$txnum,$config['showalldata']);
                }
            }else{
                $fanslist= array();
            }

            //虚拟头像
            if (count($fanslist)<$txnum && $config['fakejoin']>0){
                $tempcount = $txnum-count($fanslist);
                if ($tempcount > $config['fakejoin']){
                    $tempcount = $config['fakejoin'];
                }

                if (strstr($config['softtag0'],"婚纱")!==false ){
                    $kaishishu = intval( substr(MODULE_NAME, -1))%10*20+700;
                }else{
                    $kaishishu = intval( substr(MODULE_NAME, -1))%10*50;
                }
                if ($config['touxiang']==0){
                    $xunisql = "SELECT nickname as username,avatar FROM " . tablename('2019xuni_fans') . " where
                     id >". $kaishishu ." limit ".$tempcount;
                }else{
                    $xunisql = "SELECT username,avatar FROM " . tablename('2019xuni_fans') . " where
                     id >". $kaishishu ." limit ".$tempcount;
                }
                $xunilist = db_select ( $xunisql );
                if ($system['softstyle']!=6){
                    $fanslist = array_merge($fanslist , $xunilist);
                }
            }
            $groupsnum = Record::getFansNumByThemeId($themeid,$config['showalldata']);
            $groupsnum = intval($groupsnum)+intval($config['faketuan']);;
            //隐藏客户真实姓名
            if ($config['touxiang']>0 && $config['isshowname']==1 ){
                foreach ($fanslist as $index => $row){
                    $usernamelen=mb_strlen($row['username'],'utf-8');
                    if ($usernamelen > 2){
                        $fanslist[$index]['username']=mb_substr($row['username'],0,1,'utf-8').'*'.mb_substr($row['username'],$usernamelen-1,1,'utf-8');
                    }elseif (!empty($row['username'])){
                        $fanslist[$index]['username']='*'.mb_substr($row['username'],-1,1,'utf-8');
                    }
                }
            }
        }
    if (!empty($config['renshu'])){
        if($theme['status'] == 2 && $config['renshumode']==1){
            $totalsum = $config['renshu'];
        }
    }

    // $numarray = str_split($totalsum.'');


    if (empty($config['nametext'])){
        $config['nametext']='姓名';
    }
    if (empty($config['mobiletext'])){
        $config['mobiletext']='手机号';
    }
    // $danmulist = array();
    // if($config['isreply'] == 1){
 //        $replysum = Reply::getNumByThemeIdAndStatus($themeid,1);
 //        $replylist =Reply::getListLimit20($themeid);
 //        $danmulist = $replylist;
    // }
    //关闭小程序星星功能
//    $config['isicon']=0;
    if($config['isicon'] > 1){
        if ($config['iconhang']!=0){
            $iconwidth=$config['iconhang'];
        }else{
            if ($config['iconnum']==3 || $config['iconnum']==2 ||$config['iconnum']==1){
                $iconwidth=28;
            }elseif ($config['iconnum']==4 || $config['iconnum']==7 ||$config['iconnum']==8){
                $iconwidth=21;
            }elseif ($config['iconnum']%5==0){
                $iconwidth=16;
            }elseif ($config['iconnum']%6==0 || $config['iconnum']%6==5 || $config['iconnum']%6==4 || $config['iconnum']%5==1 || $config['iconnum']%5==2){
                $iconwidth=12;
            }else{
                $iconwidth=16;
            }
        }
        $config['iconwidth']=$iconwidth;


        $lightsum = 0;
        if($config['iconnum2'] <= 0){
            $lightsum = Share::getNumByThemeIdAndOpenidAndStatus($themeid,$_G['openid'],1);
        }else{
            if ($config['isicon']==2) {
                $config['friendlist'] = Scan::getNumByThemeIdAndOpenidXCX($themeid,$_G['member']['uid'],$config['iconlimituser']);
                $lightsum = count($config['friendlist']);
                if (empty($config['friendlist'])){
                    $config['friendlist']='';
                }
            }else{
                $lightsum = Scan::getNumByThemeIdAndOpenidAndStatus($themeid,$_G['openid'],1);
            }
            if($lightsum>0){
                $lightsum = intval($lightsum/$config['iconnum2']);
            }
        }

        if ($config['isicon']==3) {
            $help_uid = $_P['fromuid'];
            if (!empty($help_uid)){
                $friendlistuid = $help_uid;
            }elseif (!empty($themyrecord) || $config['friendorder']==1){
                $friendlistuid = $_G['member']['uid'];
            }
            //如果打开的是员工的链接，则默认为自己
            $friendworker = Worker::getThemeWorkerByUid($friendlistuid,$themeid,1);
            if (!empty($friendworker)){
                $friendlistuid = $_G['member']['uid'];
            }
            //如果开启了，只有报名的客户才可以邀请点亮，则先判断一下
            $weibaoming = 0;
            if ($config['friendorder']==0){
                $friendorder = Record::ispay($config,$friendlistuid,$themeid);
                if(empty($friendorder)){
                    $friendlistuid = $_G['member']['uid'];
                    $weibaoming = 1;
                }
            }

            if (!empty($friendlistuid)){
                $friendfans = Fans::getById($friendlistuid,$themeid);
                $lightsum = $friendfans['friendnum'];

                $params = array();
                $params[':uid'] = $_G['member']['uid'];
                $params[':fromuid'] = $help_uid;
                $params[':themeid'] = $themeid;
                $friend = db_find("SELECT * FROM ".tablename(t_friend)."
                    WHERE uid = :uid and themeid = :themeid and fromuid = :fromuid",$params);

                if(empty($friend)){
                    $isfriend = 0;
                }else{
                    $isfriend = 1;
                }
                if ($friendlistuid == $_G['member']['uid']){
                    if ($config['friendorder']==0){
                        $friendorder = Record::ispay($config,$friendlistuid,$themeid);
                        if(!empty($friendorder)){
                            $isfriend = 2;
                            $config['iconname']='邀请好友'.$config['friend_name'];
                        }else{
                            $lightsum = 0 ;
                            $isfriend = 3;
                        }
                    }else{
                        $isfriend = 2;
                        $config['iconname']='邀请好友'.$config['friend_name'];
                    }
                }
            }else{
                $lightsum = 0;
            }

            if ($lightsum >0 && $friendlistuid == $_G['member']['uid'] ){
                $params = array();
                $params[':fromuid'] = $_G['member']['uid'] ;
                $params[':themeid'] = $themeid;
                $config['friendlist'] = db_select("SELECT avatar FROM ".tablename(t_friend)."
                        WHERE themeid = :themeid and fromuid = :fromuid order by id desc LIMIT 0,".$lightsum ,$params);
                if (empty($config['friendlist'])){
                    $config['friendlist']='';
                }
            }

        }

        if ($config['iconlogo']!=1) {
            if($lightsum >= $config['iconnum']){
                $lightsum = $config['iconnum'];
            }

            $lightlist = array();
            for($i=1;$i<=$lightsum;$i++){
                $lightlist[$i]=$i;
            }
            $darksum = $config['iconnum'] ;
            $darklist = array();

            for($i=$lightsum+1;$i<=$darksum;$i++){
                $darklist[$i]=$i;
            }
        }else{
            $shoplist = db_select ( "SELECT * FROM " . tablename (t_shangjia) .
                    " WHERE  uniacid = '{$_G['mpid']}' and state = 1 and darkicon<>'' order by displayorder" );
            $iconnum = count($shoplist);

            if($lightsum >= $iconnum){
                $lightsum = $iconnum;
            }

            $lightlist = array();
            $darklist = array();
            foreach ($shoplist as $index => $item) {
                $i = $index+1;
                if ($i<=$lightsum) {
                    $lightlist[$i] = str_replace("/99.jpg","/logo.jpg",$item['logo']);
                } else {
                    $darklist[$i] = str_replace("/99.jpg","/logo.jpg",$item['darkicon']);
                }
            }
        }
        if ($config['iconlogo']!=1){
          foreach ($lightlist as $index => $item) {
            $lightlist[$index]=tomedia($config['lighticon']);
          }
          foreach ($darklist as $index => $item) {
            $darklist[$index]=tomedia($config['darkicon']);
          }
        }else{
          foreach ($lightlist as $index => $item) {
            $lightlist[$index]=tomedia($item);
          }
          foreach ($darklist as $index => $item) {
            $darklist[$index]=tomedia($item);
          }
        }
        $config['lightlist'] = $lightlist;
        $config['darklist'] = $darklist;

        $result['iconlogo'] = Theme::encode($iconlogo);
    }


    //查询是否是团员
    $mydetails = Record::getMyDetailList($fans['openid'],$themeid);
    if(!empty($mydetails)){
        foreach ($mydetails as $index =>$row){
            $mydetails[$index]['details'] = Record::getAttendDetailNumByPId($row['pid']);
        }
    }

    $isleader = 0;
    $isdetail = 0;
    $selfrecords = null;
    $showrecord = null;
    if($recordid > 0){//显示当前团信息
        $pr = $p;
        $pr[':id'] = $recordid;
        $record = Record::getAttendGroupById($recordid);
        if(!empty($record)){
            $showrecord = $record;
            if($record['openid'] == $fans['openid']){
                $isleader = 1;
            }else{
                $selfrecord = Record::getAttendGroupByOpenId($fans['openid'],$themeid);
                if(!empty($selfrecord)){
                    $selfrecord['details'] = Record::getAttendDetailNumByPId($selfrecord['id']);
                    $selfrecords[0] = $selfrecord;
                }
            }
        }else{
            $recordid = 0;
        }
    }


    if($recordid<=0){//查询是否自己是团长
        $myrecord = Record::getAttendGroupByOpenId($fans['openid'],$themeid);
        if(!empty($myrecord)){
            $showrecord = $myrecord;
            $isleader = 1;
        }
    }

    if($config['isgoon']==1){
        $selfrecords = Record::getAttendGroupListByOpenId($fans['openid'],$themeid);
        if(!empty($selfrecords)){
            foreach ($selfrecords as $index =>$row){
                $selfrecords[$index]['details'] = Record::getAttendDetailNumByPId($row['id']);
            }
        }
    }

    if(!empty($showrecord)){
        $count = Record::getAttendDetailNumByPId($showrecord['id']);
        if($count > 0){
            $detaillist = Record::getDetailListByPid($showrecord['id']);
            foreach($detaillist as $index =>$row){
                if($row['openid'] == $fans['openid']){
                    $isdetail = 1;
                    break;
                }
            }
        }

        if ($showrecord['renshu'] == 1) {
            $groupprice = $config['groupprice2'];
            $maxcount = $config['maxcountall2']-1;
            $maxcountall = $config['maxcountall2'];
        }else{
            $groupprice = $config['groupprice'];
            $maxcount = $config['maxcount'];
            $maxcountall = $config['maxcountall'];
        }

        $nowgroupneednum=max(0,$maxcount-$count);

        if ($showrecord['xunifinish']==1) {
            $kaishishu = $showrecord['uid'] % 500;
            $xunisql = "SELECT avatar,username FROM " . tablename('2019xuni_fans') . " where
                 id >". $kaishishu ." limit ".$nowgroupneednum;
            $xunilist = db_select ( $xunisql );
            if (!empty($detaillist)) {
                $detaillist = array_merge($detaillist , $xunilist);
            }else{
                $detaillist = $xunilist;
            }

            $nowgroupneednum=0;
        }else{
            $num_arr = array();
            if ($config['maxcountall']<=20){
                for($i=0;$i<$nowgroupneednum;$i++){
                    $num_arr[$i] = $i;
                }
            }
        }
    }

    if($config['isrecent'] == 1){
        $recentlist = Record::getPayEdListByThemeIding($themeid,5);
        foreach ($recentlist as $index =>$row){
            if ($row['renshu'] == 1) {
                $neednum = $config['maxcountall2']-1;
            }else{
                $neednum = $config['maxcount'];
            }
            $neednum = $neednum+1;
            $details = Record::getAttendDetailNumByPId($row['id'])+1;
            $recentlist[$index]['details']  = $details;
            $recentlist[$index]['neednum'] = $neednum;
            $leftnum = $neednum-$details;
            $recentlist[$index]['leftnum'] = $leftnum < 0?0:$leftnum;
            if($neednum<= 0){
                $neednum = 1;
            }
            $percent = round(floatval($details*100/$neednum),2);
            $recentlist[$index]['percent']  = $percent;

            if ($config['isshowname']==1 ){
                $usernamelen=mb_strlen($row['username'],'utf-8');
                if ($usernamelen > 2){
                    $recentlist[$index]['username']=mb_substr($row['username'],0,1,'utf-8').'*'.mb_substr($row['username'],$usernamelen-1,1,'utf-8');
                }elseif (!empty($row['username'])){
                    $recentlist[$index]['username']='*'.mb_substr($row['username'],-1,1,'utf-8');
                }
            }
        }
        $config['recentlist'] = $recentlist;
    }
    if (!empty($config['renshu'])){
        $jindu = round(100*$totalsum/$config['renshu'],2);
        if($jindu > 100){
            $jindu = 100;
        }

        if ($config['renshumode']==1) {
            $jindu = 100-$jindu;
        }
        if ($config['renshumode']==1 || $config['renshumode']==2) {
            if ($totalsum>=$config['renshu']) {
                db_update(t_theme, array("status"=>2), array('id' => $themeid));
                $theme['status'] = 2;
            }
        }


        if (empty($config['renshutips'])) {
            if ($config['renshumode']==0 || $config['renshumode']==2) {
                $config['renshutips'] = "限量#renshu个名额，已报名#baoming人";
            }else{
                $config['renshutips'] = "限量#renshu个名额，还剩余#shengyu个名额";
            }
        }

        if ($jindu>0 && $jindu<3) {
            $jdimg =10;
            $jindu = $jindu+2;
        }elseif ($jindu<15) {
            $jdimg =10;
        }elseif ($jindu<30) {
            $jdimg =25;
        }elseif ($jindu<60) {
            $jdimg =50;
        }elseif ($jindu<85) {
            $jdimg =75;
        }elseif ($jindu<=100) {
            $jdimg =100;
        }

        $shengyu = $config['renshu'] - $totalsum;
        if ($shengyu< 0 ){$shengyu = 0;}
        $config['renshutips'] = str_replace("#renshu", $config['renshu'], $config['renshutips']);
        $config['renshutips'] = str_replace("#baoming", $totalsum, $config['renshutips']);
        $config['renshutips'] = str_replace("#shengyu", $shengyu, $config['renshutips']);
        $config['jindu'] = $jindu;
        $config['jinduimg'] = $jdimg;

    }
    if($config['iscomm']==1){
        //发红包
        if($system['autored']== 1 || $system['autored']==2){
            $totalpayfee = Order::getRealByThemeIdnew($themeid) + $theme['chongzhi'];
            if ($totalpayfee>1){
                $row = Comm::getUnPayOneItemNew($system,$themeid);
                if(!empty($row)){
                    Fee::commRecord($row,$system);
                }
            }
        }

        //屏蔽转发红包与摇一摇红包
        if($config['iscomm']==1 && ($system['fenxiao07']==1 || $config['comm41'] > 0) && !empty($workerid)){
            $theyworker = Worker::getThemeWorkerByUid($workerid,$themeid,1);

            if (empty($theyworker) || $theyworker['comm4status']>1){
                $system['fenxiao07']=0;
                $config['comm41'] = 0;
            }
        }

        //如果只开启了员工,前台不显示排行和图标
        if ($system['fenxiao01'] >0 || $system['fenxiao04'] ==1 || $system['fenxiao05'] ==1 || $system['fenxiao07'] ==1){
           $comminfo = Comm::getcommslist($system,$config,$themeid);
           $comminfo['fenxiaotip'] =  str_replace('default/images/fenxiao','default/images/fenxiaoxcx', $comminfo['fenxiaotip']);
            $comminfo['commssum']=Comm::getcommssum($system,$themeid,$config['iscommshowfail']);
            if (!empty($config['commlistimg'])) {
                $comminfo['commlistimg']=$config['commlistimg'];
            }else{
                $comminfo['commlistimg']=$_G['URL']['FCPDD_CSS'] . "images/phb.png";
            }
            if (!empty($config['commlistimgbg'])) {
                $comminfo['commlistimgbg']=$config['commlistimgbg'];
            }else{
                $comminfo['commlistimgbg']=$_G['URL']['FCPDD_CSS'] . "images/dbg.jpg";
            }

            if (!empty($config['hbtip'])) {
                $comminfo['hbtip']=$config['hbtip'];
            }else{
                $comminfo['hbtip']=$_G['URL']['APP_IMAGE'] ."hongbao.png";
            }
            $comminfo['commlistimg']=str_replace("http://","https://",$comminfo['commlistimg']);
            $comminfo['commlistimgbg']=str_replace("http://","https://",$comminfo['commlistimgbg']);
            $comminfo['isrankrenshu'] = $config['isrankrenshu'];
            $comminfo['isrankqianshu'] = $config['isrankqianshu'];
        }
    }

    if($config['iscomm']==1 && $system['fenxiao07']==1){
        $commyaoyiyaofee = sprintf("%.2f",floatval(db_fetchcolumn ( 'SELECT sum(fee) FROM ' . tablename ( t_comm ) . "
        WHERE themeid ='{$themeid}' and type = 7 and status  = 1 " )));

        $commyaoyiyao = db_fetchcolumn ( 'SELECT count(*) FROM ' . tablename ( t_comm ) . "
        WHERE themeid ='{$themeid}' and type = 7 and status  = 1 " );
        $commyaoyiyao = $commyaoyiyao  + $config['comm7num'];
        $commyaoyiyaofee = sprintf("%.2f",$commyaoyiyaofee  + $config['comm7fee']);


        $config['commyaoyiyao']=$commyaoyiyao;
        $config['commyaoyiyaofee']=$commyaoyiyaofee;

    }

    // $poster = Poster::getByThemeIdnew($themeid);
    // if(!empty($poster['bg'])){
    //     $waittips = empty($poster['waittips'])?'正在生成海报':$poster['waittips'];
    //     $config['isposter']=1;
    //     if ($fans['status']==2 && $system['s']['istubiao']==1) {
    //         $config['isposter']=0;
    //     }

    //     $myposter = db_find("SELECT * FROM ".tablename(t_fans)."
    //         WHERE themeid = :themeid and openid = :openid",$pm);
    // }

    //显示二维码
    $showewm = 0;
    if($system['isfollow']==1 && $_G['member']['follow']==0){
        $showewm = 1;
    }


    if (intval($config['groupneedtime'])>0){
        $refundtime=strtotime('+'.intval($config['groupneedtime']).' hour',$showrecord['addtime']);
        //echo date("Y-m-d H:i:s",$refundtime);
    }else{
        $refundtime=0;
    }
    if ($config['wuxian']==1) {
        $showrecord = "";
    }



    //异业联盟的读取商家信息
    if($system['ruanjian']==3 && $config['showshop']==0){
        $isshowshop = 1;
        $grouplist = db_select ( "SELECT * FROM " . tablename (t_shangjiagroup) .
                " order by displayorder" );

        $shoptiaojian="";
        if (!empty($company)) {
            $myshop = db_find ( "SELECT * FROM " . tablename (t_shangjia) .
                " WHERE  id = '{$company}' and state = 1 order by displayorder" );
            if ($system['softstyle']!=6) {
                if ($config['homeshowshop']==0) {
                    $shoptiaojian=" and id <> '" . $company ."' ";
                }else{
                    $shoptiaojian=" and w.company <> '" . $company ."' ";
                }
            }
            $shopname = $myshop['name'];
        }

        if (!empty($grouplist) && $system['softstyle']!=0){
            foreach ($grouplist as $index => $item) {
                $shoplist = db_select ( "SELECT * FROM " . tablename (t_shangjia) .
                    " WHERE  groupid ='{$item['id']}'  and state = 1 order by displayorder" );
                $grouplist[$index]['shoplist']=$shoplist;
            }
        }else{
            if ($config['homeshowshop']==0) {
                $shoplist = db_select ( "SELECT * FROM " . tablename (t_shangjia) .
                    " WHERE  1=1 {$shoptiaojian} and state = 1 order by displayorder" );
            } else {
                $shoplist = db_select("SELECT sum(r.record) as record,s.* FROM " . tablename ( t_worker ) . " w
    left join " . tablename ( t_shangjia ) . " s on w.company = s.id
    left join " . tablename ( t_workerreport ) . " r on w.uid = r.workerid and w.themeid = r.themeid
    WHERE 1=1 {$shoptiaojian} group by w.company order by record desc,s.displayorder,s.id" );
            }



            $grouplist[0]['img']= $_G['URL']['DUOSHANGJIA_CSS'] . 'images/free.png';
            $grouplist[0]['name']='免费详情';
            $grouplist[0]['shoplist']=$shoplist;
        }

        $logolist = db_select ( "SELECT * FROM " . tablename (t_shangjia) .
                    " WHERE  state = 1 and logo<>'' order by displayorder" );

        $xunichengjiao = intval(db_fetchcolumn ( 'SELECT sum(xunichengjiao) FROM ' . tablename ( t_shangjia ) . "
                WHERE state = 1 " ));
        $totalsum = $totalsum + $xunichengjiao;
    }

    if( $config['isdanmu'] > 0 && $theme['endtime'] > TIMESTAMP && $theme['status'] == 1){
        $imgur = "https://css2019.yixuan.net/headimgs/2" . intval( substr(MODULE_NAME, -1))%5;

        $danmulist = array();
        if ($system['softstyle']!=5) {
            $limitNum=30;
            if($config['iscomm']==1){
                $commlist = Comm::getListByThemeIdNew($themeid,$limitNum,$config['danmu02'],$config['danmu03'],$config['danmu04']);
                if(!empty($commlist)){
                    foreach ($commlist as $index => $row){
                        $row['nickname']=str_replace("'","",$row['nickname']);
                        if (($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['istouxiang']==1) {
                            $row['avatar'] = $imgur .  substr($row['fansuid'], -2) . ".jpg";
                        }
                        $data = array(
                            'nickname'  => mb_substr($row['nickname'],0,5,'utf-8'),
                            'img'       => $row['avatar'],
                            'info'      => ' 刚刚获得红包 '.$row['fee'].'元',
                            );
                        $danmulist[] = $data;
                    }
                }
            }
           //  if($config['isreply'] == 1){
           //      $replylist =Reply::getListLimit20($themeid);
           //      if (!empty($replylist)){
                 //    foreach ($replylist as $index => $row){
                 //     $row['nickname']=str_replace("'","",$row['nickname']);
                 //     $data = array(
                    //      'nickname'  => mb_substr($row['nickname'],0,5,'utf-8'),
                    //      'img'       => $row['avatar'],
                    //      'info'      => ' 说:'.$row['content'],
                    //      );
                 //     $danmulist[] = $data;
                    // }
           //      }
           //  }
            if($config['isicon'] > 0 && $config['iconnum2'] == 0 && $config['danmu01']==0){
                $slist =Share::getListByThemeId($themeid,5);
                if (!empty($slist)){
                    foreach ($slist as $index => $row){
                        $row['nickname']=str_replace("'","",$row['nickname']);
                        if (($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['istouxiang']==1) {
                            $row['avatar'] = $imgur .  substr($row['fansuid'], -2) . ".jpg";
                        }
                        $data = array(
                            'nickname'  => mb_substr($row['nickname'],0,5,'utf-8'),
                            'img'       => $row['avatar'],
                            'info'      => ' 刚刚点亮1颗图标',
                            );
                        $danmulist[] = $data;
                    }
                }
            }
            $glist = Record::getLimitByIdnew($themeid,$limitNum);
            if (!empty($glist)){
                foreach ($glist as $index => $row){
                    if($row['type'] == 0){
                        if ($system['ruanjian']==1 || $system['softstyle']==7 || $config['maxcountall']<2) {
                            $row['content'] = ' 刚刚成功报名';
                        }else{
                            $row['content'] = ' 刚刚成功抢购';
                        }
                    }if($row['type'] == 1){
                        $row['content'] = ' 刚刚成功抢购';
                    }if($row['type'] == 9){
                        $row['content'] = ' 刚刚成功抢购';
                    }
                    $row['nickname']=str_replace("'","",$row['nickname']);
                    if (($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['istouxiang']==1) {
                        $row['avatar'] = $imgur .  substr($row['fansuid'], -2) . ".jpg";
                    }
                    $data = array(
                        'nickname'   => mb_substr($row['nickname'],0,5,'utf-8'),
                        'img'    => $row['avatar'],
                        'info'  => $row['content'],
                        );
                    $danmulist[] = $data;
                }
            }
        }else{
            $limitNum=30;
            if($config['iscomm']==1){
                $commlist = Comm::getListByThemeIdNew($themeid,$limitNum,$config['danmu02'],$config['danmu03'],$config['danmu04']);
                if(!empty($commlist)){
                    foreach ($commlist as $index => $row){
                        $row['nickname']=str_replace("'","",$row['nickname']);
                        if (($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['istouxiang']==1) {
                            $row['avatar'] = $imgur .  substr($row['fansuid'], -2) . ".jpg";
                        }
                        $data = array(
                            'nickname'  => mb_substr($row['nickname'],0,5,'utf-8'),
                            'img'       => $row['avatar'],
                            'info'      => ' 刚刚获得红包 '.$row['fee'].'元',
                            );
                        $danmulist[] = $data;
                    }
                }
            }
            $glist = Record::getLimitByIdnew($themeid,$limitNum);
            if (!empty($glist)){
                foreach ($glist as $index => $row){
                    if($row['type'] == 0){
                        $row['content'] = ' 刚刚成功加盟';
                    }if($row['type'] == 1){
                        $row['content'] = ' 刚刚抢购成功';
                    }if($row['type'] == 9){
                        $row['content'] = ' 刚刚抢购成功';
                    }
                    $row['nickname']=str_replace("'","",$row['nickname']);
                    if (($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['istouxiang']==1) {
                        $row['avatar'] = $imgur .  substr($row['fansuid'], -2) . ".jpg";
                    }
                    $data = array(
                        'nickname'   => mb_substr($row['nickname'],0,5,'utf-8'),
                        'img'    => $row['avatar'],
                        'info'  => $row['content'],
                        );
                    $danmulist[] = $data;
                }
            }
        }
        shuffle($danmulist);
        $danmulisttop = $danmulist;
        shuffle($danmulist);
    }
    if ($system['gift']==1) {
        if (empty($themyrecord)){
            $sql = "SELECT * FROM " . tablename ( t_gift ) . " 
                                        WHERE giftgroupid = '{$config['giftgroupid']}' and state=1 ORDER BY displayorder ";
            $giftlist = db_select ( $sql );
        }elseif(!empty($themyrecord['giftids'])){
            $ids = unserialize($themyrecord['giftids']);
            $idsstr = "";
            foreach ($ids as $index => $id){
                if($index == 0){
                    $idsstr.= "(".$id;
                }else{
                    $idsstr.= ",".$id;
                }
            }
            $idsstr.=")";
            $giftsql = "SELECT * FROM " . tablename ( t_gift ) . " WHERE id in {$idsstr} ORDER BY displayorder ";
            $hasgiftlist = db_select ( $giftsql );
            $hasgiftlcount = count($hasgiftlist);
            $jiaz = db_find ( "SELECT sum(giftjiazhi) as cnt FROM " . tablename ( t_gift ) . " WHERE id in {$idsstr}" );
            $jiazsum = $jiaz ['cnt'] <= 0 ? 0 : $jiaz ['cnt'];
        }
    }

    //邀请助力 送星星
    if ($config['isicon']==3) {
        if (!empty($help_uid)){
            $friendlistuid = $help_uid;
        }elseif (!empty($themyrecord) || $config['friendorder']==1){
            $friendlistuid = $fans['uid'];
        }
        $config['friendlistuid'] = $friendlistuid;
    }

    //待开发
    if ($system['friend']==1) {
        if (!empty($help_uid)){
            $friendlistuid = $help_uid;
        }elseif (!empty($themyrecord) || $config['friendorder']==1){
            $friendlistuid = $fans['uid'];
        }
        if (!empty($friendlistuid)){
            $friendfans = Fans::getById($friendlistuid,$themeid);
            $friendshengyu = $friendfans['friendnum']-$friendfans['friendshiyong'];
        }else{
            $friendshengyu = 0;
        }
        // if (!empty($friendlistuid)){

        //  $friendfans = Fans::getById($friendlistuid,$themeid);
        //  $params = array();
        //     $params[':uniacid'] = $_G['mpid'];
        //     $params[':uid'] = $fans['uid'];
        //     $params[':fromuid'] = $help_uid;
        //     $params[':themeid'] = $themeid;
        //     $friend = db_find("SELECT * FROM ".tablename(t_friend)."
        //      WHERE uid = :uid and themeid = :themeid and fromuid = :fromuid",$params);

        //  if(empty($friend)){
        //      $isfriend = 0;
        //  }else{
        //      $isfriend = 1;
        //  }

        //     $params = array();
        //     $params[':uniacid'] = $_G['mpid'];
        //     $params[':fromuid'] = $friendlistuid;
        //     $params[':themeid'] = $themeid;

        //  $friendlist = db_select("SELECT * FROM ".tablename(t_friend)."
        // WHERE themeid = :themeid and fromuid = :fromuid",$params);
        //  $friendshengyu = $friendfans['friendnum']-$friendfans['friendshiyong'];

        // }else{
        //  $friendshengyu = 0;
        // }

        //  $sql = "SELECT * FROM " . tablename ( t_gift ) . "
        //                              WHERE giftgroupid = '{$config['friend_groupid']}' ORDER BY displayorder ";
        //  $friendlipinlist = db_select ( $sql );

        //  foreach ($friendlipinlist as $index => $item) {
        //      if ($friendshengyu>=$item['duihuan']){
        //          $friendlipinlist[$index]['jindu'] = 100;
        //      }else{
        //          $friendlipinlist[$index]['jindu'] = intval($friendshengyu/$item['duihuan']*100);
        //      }
        //      // if ($friendlistuid == $fans['uid']){
        //          $params = array();
        //          $params[':uniacid'] = $_G['mpid'];
        //          $params[':uid'] = $friendlistuid;
        //          $params[':giftid'] = $item['id'];
        //          $params[':themeid'] = $themeid;
        //          $isduihuan = db_find("SELECT * FROM ".tablename(t_exchange)."
        //              WHERE uid = :uid and themeid = :themeid and giftid = :giftid",$params);
        //          if (!empty($isduihuan)){
        //              $friendlipinlist[$index]['isduihuan'] = 1;
        //          }
        //      // }

        //  }
    }


    //按扭文字替换通配符
    // if ($config['joinfee']=='0.00'){
    //  if (empty($config['formtextcenterxcx'])){
    //      $config['formtextcenterxcx']="发起拼团";
    //      $config['isshowprice']=2;
    //  }
    //  if (empty($config['formtextcenternewxcx'])) {
    //      $config['formtextcenternewxcx']="我要开团";
    //      $config['isshowprice']=2;
    //  }
    //  if (empty($config['formtextrightxcx'])) {
    //      $config['formtextrightxcx']="加入TA的团";
    //      $config['isshowprice']=2;
    //  }
    // }else{
    //  if (empty($config['formtextcenterxcx'])) {
    //      $config['formtextcenterxcx']="￥#fee#br发起拼团";
    //      $config['isshowprice']=1;
    //  }
    //  if (empty($config['formtextcenternewxcx'])) {
    //      $config['formtextcenternewxcx']="￥#fee#br我要开团";
    //      $config['isshowprice']=1;
    //  }
    //  if (empty($config['formtextrightxcx'])) {
    //      $config['formtextrightxcx']="￥#fee#br加入TA的团";
    //      $config['isshowprice']=1;
    //  }
    // }
    // if ($config['groupprice2']>0){
    //  if ($config['formtextcenterxcx']=="￥#fee#br发起拼团" || $config['formtextcenterxcx']=="发起拼团") {
    //      $config['formtextcenterxcx']="￥#tuan#br".$config['maxcountall']."人团";
    //      $config['isshowprice']=1;
    //  }
    //  if (empty($config['formtextcenter2xcx'])) {
    //      $config['formtextcenter2xcx']="￥#tuan#br".$config['maxcountall2']."人团";
    //      $config['formtextrightxcx']="￥#fee#br加入TA的团";
    //      $config['isshowprice']=1;
    //  }
    // }

    $formtextpay = Theme::ButtonTextReplaceXCX($config['formtextpay'],$config['joinfee'],$config['primeprice'],$config['groupprice']);

    if ($system['jiage'] > 0){
        $formtextpay = '立即支付';
        $formtextpay1 = Theme::ButtonTextReplaceXCX($config['formtextpay'],$config['joinfee'],0,0);
        $formtextpay2 = Theme::ButtonTextReplaceXCX($config['formtextpay'],$config['joinfee2'],0,0);
        $formtextpay3 = Theme::ButtonTextReplaceXCX($config['formtextpay'],$config['joinfee3'],0,0);
        $config['formtextcenterxcx']= str_replace("￥#fee#br", "", $config['formtextcenterxcx']);
        $config['formtextcenter2xcx']= str_replace("￥#fee#br", "", $config['formtextcenter2xcx']);
        $config['formtextcenternewxcx']= str_replace("￥#fee#br", "", $config['formtextcenternewxcx']);
        $config['formtextrightxcx']= str_replace("￥#fee#br", "", $config['formtextrightxcx']);
        $config['formtextleftxcx']= str_replace("￥#fee#br", "", $config['formtextleftxcx']);
        $config['isshowprice']=0;
    }

    $formtextleft = Theme::ButtonTextReplaceXCX($config['formtextleftxcx'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
    $formtextcenter = Theme::ButtonTextReplaceXCX($config['formtextcenterxcx'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
    $formtextcenter2 = Theme::ButtonTextReplaceXCX($config['formtextcenter2xcx'],$config['joinfee'],$config['primeprice'],$config['groupprice2']);
    $formtextcenternew = Theme::ButtonTextReplaceXCX($config['formtextcenternewxcx'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
    $formtextright = Theme::ButtonTextReplaceXCX($config['formtextrightxcx'],$config['joinfee'],$config['primeprice'],$groupprice);

        $wtformtextpay = Theme::ButtonTextReplaceXCX($config['wtformtextpay'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
        $wtformtextleft = Theme::ButtonTextReplaceXCX($config['wtformtextleft'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
    if ($system['softstyle']==5) {
        $jmdibuwenzi = Theme::ButtonTextReplaceXCX($config['jmdibuwenzi'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
        $jmzhifuwenzi = Theme::ButtonTextReplaceXCX($config['jmzhifuwenzi'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
        $jmzhifuwenzi2 = Theme::ButtonTextReplaceXCX($config['jmzhifuwenzi2'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
    }

    $formtextleft = str_replace("￥0.00#br","",$formtextleft);
    $formtextcenter = str_replace("￥0.00#br","",$formtextcenter);
    $formtextcenter2 = str_replace("￥0.00#br","",$formtextcenter2);
    $formtextcenternew = str_replace("￥0.00#br","",$formtextcenternew);
    $formtextright = str_replace("￥0.00#br","",$formtextright);
    $wtformtextpay = str_replace("￥0.00#br","",$wtformtextpay);
    $wtformtextleft = str_replace("￥0.00#br","",$wtformtextleft);


//待开发
    //加盟系统
    // if ($system['softstyle']==5) {
    //     $sql = "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE parentId= -1 ORDER BY displayorder desc, areaId asc";
    //     $shenglist = db_select ( $sql );
    //     foreach ($shenglist as $shengindex => $sheng) {
    //         $sql = "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE parentId= " . $sheng['areaId'] . " ORDER BY displayorder desc, areaId asc";
    //         $shilist = db_select ( $sql );
    //         $shenglist[$shengindex]['shilist']=$shilist;
    //         foreach ($shilist as $shiindex => $shi) {
    //             $sql = "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE parentId= " . $shi['areaId'] . " ORDER BY displayorder desc, areaId asc";
    //             $xianlist = db_select ( $sql );
    //             $shenglist[$shengindex]['shilist'][$shiindex]['xianlist']=$xianlist;
    //         }
    //     }
    //     if (!empty($themyrecord)){
    //         $item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $themyrecord['address']);
    //         $shengshi = $item['areaName'];
    //         if (!empty($item)) {
    //             $item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $item['parentId']);
    //             $shengshi = $item['areaName'] . $shengshi;
    //         }
    //         if (!empty($item)) {
    //             $item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $item['parentId']);
    //             $shengshi = $item['areaName'] . $shengshi;
    //         }
    //     }
    // }

    //待开发
    //二维码空缺自动补发
    // if ($system['qrlist']==1 && $config['qrlistbufa']==0 && !empty($themyrecord) && empty($themyrecord['qrimg']) ) {
    //     if ($config['qrlistmode']==0 || ($config['qrlistmode']==1 && $themyrecord['isfinish']==1)) {
    //         $sql = "SELECT * FROM " . tablename ( t_qrlist ) . "
    //             WHERE themeid = '{$themeid}' and state = 1 and usercount<qrnum ORDER BY displayorder asc, id asc ";
    //         $list = db_find ( $sql);
    //         if (!empty($list)) {
    //             db_run('set AUTOCOMMIT=0');//关闭自动提交，自此句执行以后，每个SQL语句或者语句块所在的事务都需要显示"commit"才能提交事务
    //             db_run('START TRANSACTION');//启动一个新事务
    //             $qrliststate = db_query("UPDATE ".tablename(t_qrlist)." SET usercount = usercount+1 WHERE id =".$list['id']);
    //             $recordstate = db_query("UPDATE ".tablename(t_record)." SET qrimgid = '". $list['id'] ."',qrimg ='" .$list['qrimg']."' WHERE id = ".$themyrecord['id'] );
    //             $themyrecord['qrimg'] = $list['qrimg'];
    //             if (!$qrliststate || !$recordstate) {
    //                 db_run('ROLLBACK');//事务回滚
    //             }else{
    //                 db_run('COMMIT');//事务提交
    //             }

    //         }
    //     }
    // }

    //待开发
    //抽奖：未报名的客户获得抽奖机会
    // if ($system['fanpai']==1 && $config['fanpaigroupid']>0) {
    //     $sql = "SELECT * FROM " . tablename ( t_gift ) . "
    //                                 WHERE giftgroupid = '{$config['fanpaigroupid']}' and state=1 ORDER BY displayorder ";
    //     $fanpailist = db_select ( $sql );
    //     if (count($fanpailist)<1){
    //         return_msg('抽奖礼品未设置！');
    //     }
    //     if ($config['fanpailimit'] > count($fanpailist)){
    //         return_msg('抽奖礼品设置错误：礼品数小于抽奖上限！');
    //     }
    //     if ($config['fanpaiweibaoming'] > 0){
    //         $sql = "SELECT * FROM " . tablename ( t_fanpaijihui ) . " WHERE themeid= " . $themeid . " and  uid= " . $fans['uid'] . " and type = 0";
    //         $jihuilist = db_select ( $sql );
    //         if (empty($jihuilist)){
    //             $tempdata = array(
    //                 'themeid'   => $themeid,
    //                 'uniacid'   => $_G['mpid'],
    //                 'uid'       => $fans['uid'],
    //                 'openid'    => $fans['openid'],
    //                 'nickname'  => $fans['nickname'],
    //                 'avatar'    => $fans['avatar'],
    //                 'status'    => 0,
    //                 'type'    => 0,
    //                 'jihui'    => $config['fanpaiweibaoming'],
    //                 'addtime'   => TIMESTAMP,
    //                 'workerid' => $workerid,
    //             );
    //             if ($system['hdget']==1 &&Fans::getuid_old($workerid,$themeid)) {
    //                 $data['workerid_old']  = $workerid;
    //             }
    //             $insertid = db_insert(t_fanpaijihui, $tempdata);
    //             db_query("UPDATE ".tablename(t_fans)." SET jihui = jihui + " . $config['fanpaiweibaoming'] . " WHERE themeid =:themeid and openid = :openid",$pm);
    //         }
    //     }

    //     $pm = array(":themeid"=>$themeid,":openid"=>$fans['openid']);
    //     $yichou = db_fetchcolumn("SELECT COUNT(*)  FROM ".tablename(t_fanpaichoujiang)."
    //     WHERE themeid = :themeid and openid = :openid",$pm);

    //     $jihui = $config['fanpailimit']- $yichou;

    //     $jihui =  ($jihui>$fans['jihui']) ? $fans['jihui'] : $jihui ;

    //     if ($yichou>0) {
    //         foreach ($fanpailist as $index => $row) {
    //             $choujianglist = db_find("SELECT * FROM ".tablename(t_fanpaichoujiang)."
    //             WHERE uid = :uid and themeid =:themeid and weizhi =:weizhi",array(":themeid"=>$themeid,":uid"=>$fans['uid'],":weizhi"=>$index));
    //             if(!empty($choujianglist )){
    //                 $fanpailist[$index]['newgift']=$choujianglist['giftimg'];
    //             }
    //         }
    //     }
    //     if ($config['fanpaijilu']==0) {
    //         $fanpaijilu = db_select("SELECT c.*,f.mobile FROM ".tablename(t_fanpaichoujiang)." as c
    //             left join ".tablename(t_fans)." as f on c.uid = f.uid
    //             WHERE f.themeid =:themeid and giftname<>'未中奖' order by c.id desc limit 20",array(":themeid"=>$themeid));
    //     }


    // }


    if ($config['tuanrank'] > 0){
        $tuannum = Record::getFansNumByThemeId($themeid,$config['showalldata']);
        // $groupsnum = intval($groupsnum)+intval($config['faketuan']);;

        $tuanranklist = db_select("SELECT * FROM ".tablename(t_record)."
                            WHERE themeid =" . $themeid ." and status > 0 and type = 0 ORDER BY tuannum desc,addtime desc limit " . $config['tuanrank']);
        foreach ($tuanranklist as $index => $row) {
            $usernamelen=mb_strlen($row['username'],'utf-8');
            if ($usernamelen > 2){
                $tuanranklist[$index]['username']=mb_substr($row['username'],0,1,'utf-8').'*'.mb_substr($row['username'],$usernamelen-1,1,'utf-8');
            }elseif (!empty($row['username'])){
                $tuanranklist[$index]['username']='*'.mb_substr($row['username'],-1,1,'utf-8');
            }
        }

    }
    if ($config['fansrank'] > 0){
        if ($config['isfansrankshowworker']==1) {

            $workerlist = db_select ( "SELECT uid FROM " . tablename ( t_worker ) );
            if (!empty($workerlist)){
                $workerkey = " and uid not in (\"" . implode(",",$workerlist) . "\")";
            }
            $workerkey = " and uid not in (";
            foreach ($workerlist as $key => $item) {
                if ($key==0){
                    $workerkey .= $item['uid'];
                }else{
                    $workerkey .="," . $item['uid'];
                }
            }
            $workerkey .=")";

        }else{
            $workerkey="";
        }
        $fansranklist = db_select("SELECT * FROM ".tablename(t_fans)."
                            WHERE themeid =" . $themeid . $workerkey ."  ORDER BY tuijian desc,addtime desc limit " . $config['fansrank']);
        foreach ($fansranklist as $index => $row) {
            // $usernamelen=mb_strlen($row['username'],'utf-8');
            // if ($usernamelen > 2){
            //  $fansranklist[$index]['username']=mb_substr($row['username'],0,1,'utf-8').'*'.mb_substr($row['username'],$usernamelen-1,1,'utf-8');
            // }elseif (!empty($row['username'])){
            //  $fansranklist[$index]['username']='*'.mb_substr($row['username'],-1,1,'utf-8');
            // }
            $usernamelen=mb_strlen($row['mobile'],'utf-8');
            $fansranklist[$index]['mobilenew']=mb_substr($row['mobile'],0,3,'utf-8').'****'.mb_substr($row['mobile'],$usernamelen-4,4,'utf-8');
        }

    }



    // 底部按扭
    // URL参数
        // 10补余款
        // 999邀请好友
        // 11我的定单
        // 12核销定单
        // 1开新团
        // 2加入团
        // 3单买
        // 13加入团（此团已满）
    if (!empty($config['iconname_menu']) && $config['isicon']==3 ){
        if ($isfriend==1){
            $bottombut['left']['txt'][0]= $config['friend_success'];
            $bottombut['left']['url']= 15;
        }else if ($isfriend==2){
            $bottombut['left']['txt'][0]= '邀请好友' . $config['friend_name'];
            $bottombut['left']['url']= 999;
        }elseif ($weibaoming==0){
            $bottombut['left']['txt'][0]= $config['iconname_menu'];
            $bottombut['left']['url']= 15;
        }

        if (empty($themyrecordid)){
            $bottombut['right']['txt']= explode("#br",$formtextcenter);
            $bottombut['right']['url']= 1;
        }elseif ($friendlistuid != $_G['member']['uid']){
            $bottombut['right']['txt'][0]= '我的链接';
            $bottombut['right']['url']= 16;
        }else{
            $bottombut['right']['txt'][0]= str_replace("组团", "报名", $config['lablesuccess']) ;
            $bottombut['right']['url']= 999;
        }
    }else{
        if ($config['joinfee']=='0.00' && $config['groupprice']=='0.00'){
            // echo $config['joinfee'] ."==" . $config['groupprice'] .$formtextcenter;
            if (empty($themyrecordid)){
                $bottombut['right']['txt']= explode("#br",$formtextcenter);
                $bottombut['right']['url']= 1;
            }else{
                $bottombut['right']['txt'][0]= str_replace("组团", "报名", $config['lablesuccess']) ;
                $bottombut['right']['url']= 999;
            }
        }else{
            // echo $config['joinfee'] ."==" . $config['groupprice'];
            if (empty($themyrecordid)){
                if ($config['primeprice']!='0.00'){
                    $bottombut['left']['txt']= explode("#br",$formtextleft);
                    $bottombut['left']['url']= 3;
                }
                if (empty($showrecord)){
                    if ($config['groupprice2']!='0.00'){
                        $bottombut['center']['txt']= explode("#br",$formtextcenter);
                        $bottombut['center']['url']= 1;

                        $bottombut['right']['txt']=explode("#br",$formtextcenter2);
                        $bottombut['right']['url']= 4;
                    }else{
                        if ($config['primeprice']=='0.00'){
                            $bottombut['right']['txt'][0]= str_replace("#br", "", $formtextcenter);
                        }else{
                            $bottombut['right']['txt']=explode("#br",$formtextcenter);
                        }
                        $bottombut['right']['url']= 1;
                    }
                }elseif ($config['groupprice2']!='0.00'){
                    // $bottombut['center']['txt']= $formtextcenternew;
                    // $bottombut['center']['url']= 1;

                    // $txt .= "     <a href=\"javascript:;\" onclick=\"";
                    // $txt .= "swithmenu()";
                    // $txt .= "\" class=\"teamBtn dh2\">\n";
                    // $txt .= $formtextcenternew;
                    // $txt .= "     </a>\n";

                    $bottombut['right']['txt']= explode("#br",$formtextright);
                    if ($nowgroupneednum<=0 && $config['tuanmode']==0) {
                        $bottombut['right']['url']= 13;
                    }else{
                        $bottombut['right']['url']= 2;
                    }
                }else{
                    $bottombut['center']['txt']= explode("#br",$formtextcenternew);
                    $bottombut['center']['url']= 1;

                    $bottombut['right']['txt']= explode("#br",$formtextright);
                    if ($nowgroupneednum<=0 && $config['tuanmode']==0) {
                        $bottombut['right']['url']= 13;
                    }else{
                        $bottombut['right']['url']= 2;
                    }
                }
            }else{
                //若开启补余款
                if ($config['yukuan']>0 && TIMESTAMP>$config['yukuantime']){
                    $orderpay = db_fetchcolumn ( 'SELECT sum(realfee) FROM ' . tablename ( t_order ) . "
                        WHERE themeid = '{$themeid}' and paystate = 1 and realfee > 0 and uid='{$fans['uid']}'" );
                    $orderpay = sprintf("%.2f",$config['yukuan'] - $orderpay);
                    if ($orderpay>0) {
                        $bottombut['right']['txt'][0]= "立即补余款" . $orderpay . "元";
                        $bottombut['right']['url']= 10;
                    }else{
                        $bottombut['right']['txt'][0]= $config['lablegspy'];
                        $bottombut['right']['url']= 999;
                    }
                }else{
                    if ($config['ishexiao']==1){
                        $bottombut['left']['url']= 12;
                    }else{
                        $bottombut['left']['url']= 11;
                    }

                    if ($config['maxcount']>0){
                        if ($themyrecord['type']==9){
                            $bottombut['left']['txt'][0]= "单买号:" . $themyrecordid ;
                        }else{
                            $bottombut['left']['txt'][0]= "团号:" . $themyrecordid ;
                        }
                    }else{
                        $bottombut['left']['txt'][0]= "定单号:" . $themyrecordid ;
                    }
                    $bottombut['left']['txt'][1]= "点击查看我的定单";

                    $bottombut['right']['url']= 999;
                    if ($themyrecord['type']!=9 && $config['maxcount']>0){
                        $bottombut['right']['txt'][0]= $config['lableleadergs'];
                    }else{
                        $bottombut['right']['txt'][0]= $config['lableleadergs'];
                    }
                }
            }
        }
    }
    if ($system['ruanjian']==1) {
        if ($config['joinfee']=='0.00'){
            $config['formtextpay'] =  $wtformtextleft;
        }else{
            $config['formtextpay'] =  $wtformtextpay;
        }
    }else{
        if ($config['yukuan']>0 && TIMESTAMP>$config['yukuantime']){
            $config['formtextpay'] =  "立即支付";
        }elseif ($config['joinfee']=='0.00' && $config['groupprice']=='0.00'){
            $config['formtextpay'] =  $formtextcenter;
        }elseif ($config['joinfee']=='0.00'){
            $config['formtextpay'] =  "点击支付报名费";
        }else{
            $config['formtextpay'] =  $formtextpay;
        }
    }


    $config['shareinfo'] =Theme::getshareinfo($theme,$config,$fans,$shopname,$workername,$recordid,$_P['fromuid']);

    $fromuid = $_P['fromuid'];
    $fopenid = $_P['fopenid'];


    $bindex=1;
    if ($config['primeprice']!='0.00'){
        $bindex = $bindex + 1;
    }

    $member = db_find("SELECT * FROM ".tablename(t_fans)."
            WHERE themeid = :themeid and openid = :openid",$pm);


    if (!empty($showrecord) && $system['softstyle']!=7 && $config['maxcountall']>1){
        $nowrecorddetail = array();
        $data = array();
        // $data['img'] = tomedia($showrecord['avatar']);
        // $nowrecord[] = $data;

        if (!empty($detaillist)){
            foreach ($detaillist as $cindexno => $item) {
                $data['img'] = tomedia($item['avatar']);
                $nowrecorddetail[] = $data;
            }
        }
        if (!empty($num_arr)){
            foreach ($num_arr as $cindexno => $item) {
                $data['img'] = $_G['URL']['FCPDD_CSS'] . "images/ask.png";
                $nowrecorddetail[] = $data;
            }
        }
        if ($nowgroupneednum<=0 && $config['tuanmode']==0) {
            $tips = "此团已拼团成功";
        }elseif ($nowgroupneednum<=0 && $config['tuanmode']==1) {
            $tips = "已拼团成功,好友还可继续加入,共享福利";
        }else{
            $tips = "此团还差" . $nowgroupneednum . "人 立即加入";
        }
        $nowrecord  = array(
            'tips' => $tips,
            'zhang' => $showrecord,
            'detail' => $nowrecorddetail,
        );

    }

    if (!empty($config['buttontips'])){
        $config['buttontips'] = str_replace("#totalsum",$totalsum,$config['buttontips']);
        $config['buttontips'] = str_replace("#groupsnum",$groupsnum,$config['buttontips']);
        $config['buttontips'] = str_replace("#scansum",$scansum,$config['buttontips']);
    }

    if ($config['shopstype'] == 4) {
        if (!empty($config['options'])) {
            foreach ($config['options'] as $index => $item) {
                $config['options2'][$index]['name']=$item;
                $config['options2'][$index]['checked']=false;
            }
        }
        $config['gudingoptions_txt']="";
        if (!empty($config['gudingoptions'])) {
            foreach ($config['gudingoptions'] as $index => $item) {
                $config['gudingoptions_txt']=$config['gudingoptions_txt'] . $item . "|";
            }
        }
    }


    if (count($fanslist )>20) {
        $fanszs = count($fanslist);
        $fanszs = $fanszs - ($fanszs %5);
        $fanslist = array_slice($fanslist,0,$fanszs);
    }

    //如果获取到了手机号则关闭
    if(!isset($config['getmobile'])){
        $config['getmobile']=2;
    }
    if(!isset($config['getavatar'])){
        $config['getavatar']=1;
    }
    if ($config['getmobile']>0 && $fans['mobile']!='') {
        $config['getmobile'] = 0;
    }
    if ($config['getavatar'] >0 && $fans['avatar']!=''&& $fans['nickname']!='') {
        $config['getavatar'] = 0;
    }


    $worker['workerid'] = $workerid;
    $worker['name'] = $workername;
    $worker['company'] = $company;
    $worker['mobile'] = $workermobile;
    //待开发
    $worker['wechat'] = $wechat;
    $worker['qrcode'] = $workerqr;
    $worker['poster'] = $workerposter;
    if (!empty($myworker)){
        $worker['isworker'] = true;
    }else{
        $worker['isworker'] = false;
    }


    $theme['wechat'] = $theme['mobile'];

    $theme['mobile'] = substr($theme['mobile'],0,13);

    if (empty($config['contentxcx'])) {
        $config['contentxcx']=Poster::getContentvideoimg($config['content']);
    }
    if (empty($config['livecontentxcx']) && !empty($config['livecontent'])) {
        $config['livecontentxcx']=Poster::getContentvideoimg($config['livecontent']);
    }


if (($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['isjpeg']==1) {
    if (strripos($config['headlogo'], '.jpeg')) {
        $config['headlogo']=str_replace(".jpeg",".jpg",$config['headlogo']);
    }
    if (!empty($config['bannerimgs'])){
        foreach ($config['bannerimgs'] as $index => $row){
            if (strripos($row, '.jpeg')) {
                unset($config['bannerimgs'][$index]);
            }
        }
    }
    if (!empty($config['imgs'])){
        foreach ($config['imgs'] as $index => $row){
            if (strripos($row, '.jpeg')) {
                unset($config['imgs'][$index]);
            }
        }
    }
    if (!empty($config['centerimgs'])){
        foreach ($config['centerimgs'] as $index => $row){
            if (strripos($row, '.jpeg')) {
                unset($config['centerimgs'][$index]);
            }
        }
    }
    if (!empty($config['contentxcx'])){
        foreach ($config['contentxcx'] as $index => $row){
            if (strripos($row['url'], '.jpeg')) {
                unset($config['contentxcx'][$index]);
            }
        }
    }
    if (!empty($config['livecontentxcx'])){
        foreach ($config['livecontentxcx'] as $index => $row){
            if (strripos($row['url'], '.jpeg')) {
                unset($config['livecontentxcx'][$index]);
            }
        }
    }
    if (strripos($theme['addimg'], '.jpeg')) {
        $theme['addimg']="";
    }
}

//如果开启了员工海报图
if (!empty($workerposter)){
    if (count($config['bannerimgs'])<2 && empty($config['bannervideo'])){
        $config['headlogo'] = $workerposter;
    }else{
        array_push($config['bannerimgs'],$workerposter);
    }
}


//水印处理
if ((DOMAIN0 == "30.yixuan.net" || ($theme['endtime']+$endday) < TIMESTAMP || (!empty($theme['jiezhang']) && $theme['status']==2)) && $theme['yixuanbanquan']==0 && empty($theme['USERJISHU'])) {

        if($_G['companyname'] =='飞驰软件'){
            $imgright = "/92.jpg";
        }else{
            $imgright = "/91.jpg";
        }
        $config['headlogo']=str_replace("/99.jpg",$imgright,$config['headlogo']);

        if (!empty($config['bannerimgs'])){
            foreach ($config['bannerimgs'] as $index => $row){
                $config['bannerimgs'][$index]=str_replace("/99.jpg",$imgright,$row);
            }
        }
        if (!empty($config['imgs'])){
            foreach ($config['imgs'] as $index => $row){
                $config['imgs'][$index]=str_replace("/99.jpg",$imgright,$row);
            }
        }
        if (!empty($config['centerimgs'])){
            foreach ($config['centerimgs'] as $index => $row){
                $config['centerimgs'][$index]=str_replace("/99.jpg",$imgright,$row);
            }
        }
        if (!empty($config['contentxcx'])){
            foreach ($config['contentxcx'] as $index => $row){
                $config['contentxcx'][$index]['url']=str_replace("/99.jpg",$imgright,$row['url']);
            }
        }
        if (!empty($config['livecontentxcx'])){
            foreach ($config['livecontentxcx'] as $index => $row){
                $config['livecontentxcx'][$index]['url']=str_replace("/99.jpg",$imgright,$row['url']);
            }
        }

}

    if ($system['live']==1 && $config['livedata']['yure']==1 && in_array($config['livedata']['livestatus'], array(101,102,105,106))) {
        if (empty($config['liveheadlogo'])) {
            $config['liveheadlogo'] = $config['headlogo'];
        }
        if (!empty($config['livecontentxcx'])) {
            $config['contentxcx']=$config['livecontentxcx'];
        }
        if(!empty($config['livedata']['lname'])){
            $theme['title']=$config['livedata']['lname'];
        }
        $theme['endtime'] = $config['livedata']['livetime'];
    }else{
        $config['liveheadlogo'] = $config['headlogo'];
        $config['livedata']['yure']=0;
    }

    if ($system['live']==1){
        if ($config['livedata']['liveid']>0 ){
            if (in_array($config['livedata']['livestatus'], array(101,102,105,106))) {
                $config['livedata']['isshow']=true;
            }
            if ($config['livedata']['relive']==1 && $config['livedata']['livestatus']==103){
                $config['livedata']['isshow']=true;
            }
            $config['livedata']['livetime1']=date("Y/m/d", $config['livedata']['livetime']);
            $config['livedata']['livetime2']=date("H:i", $config['livedata']['livetime']);
        }
        $config['livedata']['livetime']=date("Y-m-d H:i:s", $config['livedata']['livetime']);
    }

    $confignew = array(
        "options" =>$config['options'],
        "shops" =>$config['shops'],
        "addressoptions" =>$config['addressoptions'],
        "address" =>$config['address'],
        "datetime" =>$config['datetime'],
        "getmobile" =>$config['getmobile'],
        "getavatar" =>$config['getavatar'],
        "options2" =>$config['options2'],
        "gudingoptions" =>$config['gudingoptions'],
        "livedata" =>$config['livedata'],
        "shopstype" =>$config['shopstype'],
        "videotime" =>$config['videotime'],
        "addresstype" =>$config['addresstype'],
        "gudingoptions_txt" =>$config['gudingoptions_txt'],
        "nametext" =>$config['nametext'],
        "mobiletext" =>$config['mobiletext'],
        "datetimetype" =>$config['datetimetype'],
        "xieyi" =>$config['xieyi'],
        "formcolortop" =>$config['formcolortop'],
        "formcolorhead" =>$config['formcolorhead'],
        "shopsmax" =>$config['shopsmax'],
        "shopsmin" =>$config['shopsmin'],
        "liveheadlogo" =>$config['liveheadlogo'],
        "formcolorcenter" =>$config['formcolorcenter'],
        "bannerimgs" =>$config['bannerimgs'],
        "bannervideo" =>$config['bannervideo'],
        "headlogo" =>$config['headlogo'],
        "istime" =>$config['istime'],
        "iswttouxiang" =>$config['iswttouxiang'],
        "renshu" =>$config['renshu'],
        "jinduimg" =>$config['jinduimg'],
        "jindu" =>$config['jindu'],
        "renshudanwei" =>$config['renshudanwei'],
        "renshutips" =>$config['renshutips'],
        "issearch" =>$config['issearch'],
        "startextcolor" =>$config['startextcolor'],
        "isrecent" =>$config['isrecent'],
        "recentlist" =>$config['recentlist'],
        "iscommshow24" =>$config['iscommshow24'],
        "iscommshow" =>$config['iscommshow'],
        "iscomm" =>$config['iscomm'],
        "commyaoyiyao" =>$config['commyaoyiyao'],
        "commyaoyiyaofee" =>$config['commyaoyiyaofee'],
        "starbgcolor" =>$config['starbgcolor'],
        "isicon" =>$config['isicon'],
        "lightlist" =>$config['lightlist'],
        "darklist" =>$config['darklist'],
        "friendlist"=>$config['friendlist'],
        "iconwidth" =>$config['iconwidth'],
        "starbtcolor" =>$config['starbtcolor'],
        "iconname" =>$config['iconname'],
        "friend_success"=>$config['friend_success'],
        "centerimgs" =>$config['centerimgs'],
        "buttontips" =>$config['buttontips'],
        "musicsrc" =>$config['musicsrc'],
        "shopsmax" =>$config['shopsmax'],
        "formtextpay" =>$config['formtextpay'],
        "ishbicon" =>$config['ishbicon'],
        "mappoint" =>$config['mappoint'],
        "addimgxcx" =>$theme['addimgxcx'],
        "addresstxt" => $config['province'].$config['city'].$config['district'].$config['addresstxt'],
    );
    $themenew = array(
        "title" =>$theme['title'],
        "mobile" =>$theme['mobile'],
        "wechat" =>$theme['wechat'],
        "jubf" =>$theme['jubf'],
    );
    $endtimearr = array(date("Y-m-d H:i:s", $theme['endtime']));
    //个别配置隐藏

    $result =  array();
    $result['fansstatus'] =$fans['status'];
    $result['system'] = self::systemnew($system);
    $result['jishu']=Worker::getjishu($theme,$system,$config['pinpailogo']);
    $result['theme']=$themenew;
    $result['config']=$confignew;
    $result['shareinfo']=$config['shareinfo'];
    $result['worker']=$worker;
    $result['isthemyrecord']=empty($themyrecord)?0:1;
    $result['contentxcx']=$config['contentxcx'];
    $result['totalsum']=$totalsum;
    $result['scannum']=$scannum;
    $result['groupsnum']=$groupsnum;
    $result['fanslist']=array_chunk($fanslist,5);
    $result['comminfo']=$comminfo;
    $result['nowrecord'] = $nowrecord;
    $result['isshowshop'] = $isshowshop;
    $result['tuanranklist'] = $tuanranklist;
    $result['fansranklist'] = $fansranklist;
    // $result['poster'] = $poster;
    // $result['myposter'] = $myposter;
    $result['danmulist'] = $danmulist;
    $result['danmulisttop'] = $danmulisttop;
    $result['endtime']=$endtimearr;
    $result['bottombut']=$bottombut;
    $result['islogin'] = empty($fans['avatar'])?true:false;
    $result['isfriend'] = $isfriend;

    $this->result(0, '成功', $result);
}
}